package com.kimho.receipt.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.kimho.core.PageInfo;
import com.kimho.cuttrucker.domain.CutTrucker;
import com.kimho.inhouse.domain.Inhouse;
import com.kimho.receipt.service.ReceiptService;
import com.kimho.user.domain.User;

@Controller
@RequestMapping("/receipt")
public class ReceiptController {

	@Autowired
	private ReceiptService receiptService;
	
	@RequestMapping(value = "/getallreceipt", method = RequestMethod.POST)
	public @ResponseBody Map<String, Object> getAllReceipt(HttpServletRequest request,
			HttpServletResponse response) {
		Map<String, Object> responseMap = new HashMap<String, Object>();
		PageInfo pi = new PageInfo(request);
		pi.setQueryParam("query", request.getParameter("query"));
		pi.setQueryParam("over", "0");//查询出已接车的物件
		pi.setQueryParam("cost_type", "13");//查询签单回付的物件
		if((User)request.getSession().getAttribute("user")!=null && ((User)request.getSession().getAttribute("user")).getPost_id()!=1){//如果登陆用户的较色不是1(经理),就只查询登陆地点的数据
			pi.setQueryParam("login_location", request.getSession().getAttribute("login_localtion"));
		}
		List<Inhouse> inhoses = this.receiptService.getAllReceipt(pi);
		responseMap.put("rows", inhoses);
		responseMap.put("totalCount", this.receiptService.getTotal(pi));
		return responseMap;
	}
}
